<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>首页</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <link rel="stylesheet" href="/lib/layui-v2.6.3/css/layui.css" media="all">
    <link rel="stylesheet" href="/lib/font-awesome-4.7.0/css/font-awesome.min.css" media="all">
    <link rel="stylesheet" href="/css/public.css" media="all">
    <script src="/js/xkube.js?v=1" charset="utf-8"></script>
    <script src="/lib/layui-v2.6.3/layui.js" charset="utf-8"></script>
    <script src="/js/lay-config.js?v=1.0.4" charset="utf-8"></script>

    <style>
        .layui-card {border:1px solid #f2f2f2;border-radius:5px;}
        .icon {margin-right:10px;color:#1aa094;}
        .icon-cray {color:#ffb800!important;}
        .icon-blue {color:#1e9fff!important;}
        .icon-tip {color:#ff5722!important;}
        .layuimini-qiuck-module {text-align:center;margin-top: 10px}
        .layuimini-qiuck-module a i {display:inline-block;width:100%;height:60px;line-height:60px;text-align:center;border-radius:2px;font-size:30px;background-color:#F8F8F8;color:#333;transition:all .3s;-webkit-transition:all .3s;}
        .layuimini-qiuck-module a cite {position:relative;top:2px;display:block;color:#666;text-overflow:ellipsis;overflow:hidden;white-space:nowrap;font-size:14px;}
        .welcome-module {width:100%;height:210px;}
        .panel {background-color:#fff;border:1px solid transparent;border-radius:3px;-webkit-box-shadow:0 1px 1px rgba(0,0,0,.05);box-shadow:0 1px 1px rgba(0,0,0,.05)}
        .panel-body {padding:10px}
        .panel-title {margin-top:0;margin-bottom:0;font-size:12px;color:inherit}
        .label {display:inline;padding:.2em .6em .3em;font-size:75%;font-weight:700;line-height:1;color:#fff;text-align:center;white-space:nowrap;vertical-align:baseline;border-radius:.25em;margin-top: .3em;}
        .layui-red {color:red}
        .main_btn > p {height:40px;}
        .layui-bg-number {background-color:#F8F8F8;}
        .layuimini-notice:hover {background:#f6f6f6;}
        .layuimini-notice {padding:7px 16px;clear:both;font-size:12px !important;cursor:pointer;position:relative;transition:background 0.2s ease-in-out;}
        .layuimini-notice-title,.layuimini-notice-label {
            padding-right: 70px !important;text-overflow:ellipsis!important;overflow:hidden!important;white-space:nowrap!important;}
        .layuimini-notice-title {line-height:28px;font-size:14px;}
        .layuimini-notice-extra {position:absolute;top:50%;margin-top:-8px;right:16px;display:inline-block;height:16px;color:#999;}
    </style>
</head>
<body>
<blockquote class="layui-elem-quote layui-text">
    快速入门:进入K8S管理-->全部k8s-->添加,添加k8s配置以后即可开始管理了
</blockquote>
<div class="layuimini-container">
    <div class="layuimini-main">
        <div class="layui-row layui-col-space15">
            <div class="layui-col-md8">
                <div class="layui-row layui-col-space15">
                    <div class="layui-col-md6">
                        <div class="layui-card">
                            <div class="layui-card-header"><i class="fa fa-credit-card icon icon-blue"></i>快捷入口</div>
                            <div class="layui-card-body">
                                <div class="welcome-module">
                                    <div class="layui-row layui-col-space10 layuimini-qiuck">                                        
                                        <!-- fenge -->
                                        <div class="layui-col-xs3 layuimini-qiuck-module">
                                            <a href="javascript:;" layuimini-content-href="page/xkube/clusterList.html?v=1" data-title="集群列表" data-icon="fa fa-home">
                                                <i class="fa fa-home"></i>
                                                <cite>K8S管理</cite>
                                            </a>
                                        </div>
                                        <div class="layui-col-xs3 layuimini-qiuck-module">
                                            <a href="javascript:;" layuimini-content-href="page/xkube/nodeList.html?v=1" data-title="节点" data-icon="fa fa-server">
                                                <i class="fa fa-server"></i>
                                                <cite>节点列表</cite>
                                            </a>
                                        </div>
                                        <div class="layui-col-xs3 layuimini-qiuck-module">
                                            <a href="javascript:;" layuimini-content-href="page/xkube/deployList.html?v=1" data-title="无状态" data-icon="fa fa-codepen">
                                                <i class="fa fa-codepen"></i>
                                                <cite>deploy列表</cite>
                                            </a>
                                        </div>
                                        <div class="layui-col-xs3 layuimini-qiuck-module">
                                            <a href="javascript:;" layuimini-content-href="page/xkube/serviceList.html?v=1" data-title="服务[service]" data-icon="fa fa-cube">
                                                <i class="fa fa-cube"></i>
                                                <cite>service列表</cite>
                                            </a>
                                        </div>
                                        <div class="layui-col-xs3 layuimini-qiuck-module">
                                            <a href="javascript:;" layuimini-content-href="page/xkube/ingressList.html?v=1" data-title="路由[ingress]" data-icon="fa fa-object-group">
                                                <i class="fa fa-object-group"></i>
                                                <cite>ingress</cite>
                                            </a>
                                        </div>
                                        <div class="layui-col-xs3 layuimini-qiuck-module">
                                            <a href="javascript:;" layuimini-content-href="page/xkube/configmapList.html?v=1" data-title="配置项[cm]" data-icon="fa fa-file-code-o">
                                                <i class="fa fa-file-code-o"></i>
                                                <cite>configmap</cite>
                                            </a>
                                        </div>
                                        <div class="layui-col-xs3 layuimini-qiuck-module">
                                            <a href="javascript:;" layuimini-content-href="page/xkube/secretList.html?v=1" data-title="保密字典" data-icon="fa fa-expeditedssl">
                                                <i class="fa fa-expeditedssl"></i>
                                                <cite>secret</cite>
                                            </a>
                                        </div>
                                        <div class="layui-col-xs3 layuimini-qiuck-module">
                                            <a href="javascript:;" layuimini-content-href="page/xkube/appnameList.html?v=1" data-title="应用集" data-icon="fa fa-joomla">
                                                <i class="fa fa-cubes"></i>
                                                <cite>应用列表</cite>
                                            </a>
                                        </div>
                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>
                    
                    <div class="layui-col-md6">
                        <div class="layui-card">
                            <div class="layui-card-header"><i class="fa fa-credit-card icon icon-blue"></i>快捷入口</div>
                            <div class="layui-card-body">
                                <div class="welcome-module">
                                    <div class="layui-row layui-col-space10 layuimini-qiuck">                                        
                                        <!-- fenge -->
                                        <div class="layui-col-xs3 layuimini-qiuck-module">
                                            <a href="javascript:;" layuimini-content-href="page/xkube/namespaceCreate.html" data-title="创建NS" data-icon="fa fa-columns">
                                                <i class="fa fa-columns"></i>
                                                <cite>创建命名空间</cite>
                                            </a>
                                        </div>
                                        <div class="layui-col-xs3 layuimini-qiuck-module">
                                            <a href="javascript:;" layuimini-content-href="page/xkube/deployCreate.html" data-title="创建deploy" data-icon="fa fa-dropbox">
                                                <i class="fa fa-dropbox"></i>
                                                <cite>创建deployment</cite>
                                            </a>
                                        </div>
                                        <div class="layui-col-xs3 layuimini-qiuck-module">
                                            <a href="javascript:;" layuimini-content-href="page/xkube/serviceCreate.html" data-title="创建svc" data-icon="fa fa-cogs">
                                                <i class="fa fa-cogs"></i>
                                                <cite>创建service</cite>
                                            </a>
                                        </div>
                                        <div class="layui-col-xs3 layuimini-qiuck-module">
                                            <a href="javascript:;" layuimini-content-href="page/xkube/ingressCreate.html" data-title="创建ing" data-icon="fa fa-gg-circle">
                                                <i class="fa fa-gg-circle"></i>
                                                <cite>创建ingress</cite>
                                            </a>
                                        </div>
                                        <div class="layui-col-xs3 layuimini-qiuck-module">
                                            <a href="javascript:;" layuimini-content-href="page/xkube/configmapCreate.html" data-title="创建CM" data-icon="fa fa-database">
                                                <i class="fa fa-database"></i>
                                                <cite>创建configmap</cite>
                                            </a>
                                        </div>
                                        <div class="layui-col-xs3 layuimini-qiuck-module">
                                            <a href="javascript:;" layuimini-content-href="page/xkube/secretCreate.html" data-title="创建secret" data-icon="fa fa-expeditedssl">
                                                <i class="fa fa-expeditedssl"></i>
                                                <cite>创建secret</cite>
                                            </a>
                                        </div>
                                        <div class="layui-col-xs3 layuimini-qiuck-module">
                                            <a href="javascript:;" layuimini-content-href="page/xkube/hpaCreate.html" data-title="创建hpa" data-icon="fa fa-ge">
                                                <i class="fa fa-ge"></i>
                                                <cite>创建HPA</cite>
                                            </a>
                                        </div>
                                        <div class="layui-col-xs3 layuimini-qiuck-module">
                                            <a href="javascript:;" layuimini-content-href="page/wiki/add.html" data-title="写文章" data-icon="fa fa-edit">
                                                <i class="fa fa-edit"></i>
                                                <cite>创作文章</cite>
                                            </a>
                                        </div>
                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>
 
                    <div class="layui-col-md12">
                        <div class="layui-card">
                            <div class="layui-card-header"><i class="fa fa-line-chart icon"></i>资源统计-----该部分数据是访问相应资源列表后统计存入redis并读出</div>
                            <div class="layui-card-body">
                                <table class="layui-table" id="clusterTableId" lay-filter="clusterTableFilter"></table>
                            </div>
                        </div>
                        <!--
                        <div class="layui-card">
                            <div class="layui-card-header"><i class="fa fa-line-chart icon"></i>报表统计</div>
                            <div class="layui-card-body">
                                <div id="echarts-records" style="width: 100%;min-height:500px"></div>
                            </div>
                        </div>
                        -->
                    </div>
                </div>
            </div>

            <div class="layui-col-md4">

              <!--
                <div class="layui-card">
                    <div class="layui-card-header"><i class="fa fa-bullhorn icon icon-tip"></i>系统公告</div>
                    <div class="layui-card-body layui-text">
                    </div>
                </div>
              -->

                <div class="layui-card">
                    <div class="layui-card-header"><i class="fa fa-fire icon"></i>最新文章</div>
                    <div class="layui-card-body">
                        <table class="layui-table" id="ListArticle" lay-filter="ListArticle"></table>
                    </div>
                </div>

                <div class="layui-card">
                    <div class="layui-card-header"><i class="fa fa-paper-plane-o icon"></i>集群事件:<i id="myclusterid"></i></div>
                    <div class="layui-card-body layui-text layadmin-text">
                      <table class="layui-table" id="currentTableId" lay-filter="currentTableFilter"></table>
                    </div>
                </div>

            </div>
        </div>
    </div>
</div>
</body>
<script type="text/html" id="TitleInfoTpl">
  <a href="javascript:;" layuimini-content-href="page/wiki/read.html?id={{ d.id }}&key=content" data-title="wiki:{{ d.title }}" class="layui-table-link">{{ d.title }}</a>
</script>

<script>

var clusterId = getQueryString("clusterId");
if (clusterId == null) {
	clusterId = getCookie("clusterId")
}

    layui.use(['layer','table', 'miniTab'], function () {
        var $ = layui.jquery,
            layer = layui.layer,
            table = layui.table,
            miniTab = layui.miniTab;

        //console.log(layui.$.fn.jquery);

        miniTab.listen();
        $('#myclusterid').html(clusterId);

        if ( clusterId == "" || clusterId == null ) {
        		layer.msg('先设置常用集群',{icon:0,time:2000},function(){
                miniTab.openNewTabByIframe({
                    href:"page/xkube/clusterList.html",
                    title:"集群列表",
                });
            });
        }

        table.render({
        		elem: '#ListArticle'
        		,url: '/wiki/v1/List' + location.search
        		,limit:10
        		,cols: [[
              {field:'id', width:60, sort: true,title:'ID',hide:true}
        			,{field:'title',sort: true,templet: '#TitleInfoTpl',title:'标题'}
        			,{field:'updatetime',sort: true, width: 170,title:'更新时间'}
        		]]
    				,error: function(xhr, status, error) {
                console.log(error);
        				layer.msg('获取信息失败',{icon:2});
      			}            
        		//,id: 'ListArticle'
            //,done: function (res, curr, count) {
            //      $('th').hide()
            //}
        });

        if ( clusterId != "" && clusterId != null ) {
          table.render({
              elem: '#currentTableId',
              url: '/xkube/event/v1/List?clusterId='+clusterId+"&limit=10",
              cols: [[
                  {field: 'objName',title: '名称', sort: true},                                
                  {field: 'message',title: '消息', sort: true},
                  {field: 'createTime',title: '创建时间'}
              ]]
          });
        }

        table.render({
            elem: '#clusterTableId',
            url: '/xkube/cluster/v1/Count',
            //totalRow: true,
            cols: [[
                //{type: 'checkbox', width:80, fixed: 'left', unresize: true, sort: true, totalRowText: '合计'},
                {field: 'clusterId', title: '集群id', sort: true},
                {field: 'node', title: '节点数', sort: true, totalRow: true},
                {field: 'deploy',  title: 'deploy数', sort: true, totalRow: true},
                {field: 'pod',  title: 'pod数', sort: true, totalRow: true},
                {field: 'service',  title: 'service数', sort: true, totalRow: true},
                {field: 'cronjob',  title: 'cronjob数', sort: true, totalRow: true},
                {field: 'configmap',  title: 'configmap数', sort: true, totalRow: true},
                {field: 'secret',  title: 'secret数', sort: true, totalRow: true}
            ]],
            limit: 25,
            done: function (res, curr, count) {
      					if ( res.msg == "NoLogin" ) {
      						layer.msg('请先登陆',{icon:2});
      					}
                //if (count == 0) { //会导致三个表都不显示数据
                //    $(".layui-table-main").html('<div class="layui-none">无数据</div>');
                //}
            },
    				error: function(xhr, status, error) {
        				layer.msg('获取信息失败',{icon:2});
      			}
        });

        // echarts 窗口缩放自适应
        //window.onresize = function(){
        //    echartsRecords.resize();
        //}

    });
</script>
</html>
